<template>
    <div>
        <table border="1">
            <tbody>
                <tr>
                    <th>名称</th>
                    <th>
                        <input type="text" v-model="data.Name">
                    </th>
                </tr>
                <tr>
                    <th>房间号</th>
                    <th>
                        <input type="text" v-model="data.Num">
                    </th>
                </tr>
                <tr>
                    <th>状态</th>
                    <th>
                        <input type="checkbox" v-model="data.State">选中启用否则禁用
                    </th>
                </tr>
                <tr>
                    <th>
                        <input type="button" value="添加" @click="Add">
                    </th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const data=ref({
    "Id": 0,
  "Name": "",
  "Num": "",
  "State": true,
  "CreateTime": "2025-04-14T01:54:44.130Z"
})

const rou=useRouter();

const Add=()=>{
    axios.post("https://localhost:7034/api/Member/AddMember",data.value).then(res=>{
        if(res.data>0){
            alert('添加成功')
            rou.push({path:'/ShowView'})
        }
        else{
            alert('失败')
        }
    })
}


</script>

